package com.suning.sawp.service.impl.oga;

import java.util.List;
import java.util.Map;

import org.joda.time.LocalDate;
import org.springframework.stereotype.Service;

import com.google.common.collect.Maps;
import com.suning.sawp.dto.oga.bi.SimpleRange;
import com.suning.sawp.po.bi.BIStaffDevelopSale;
import com.suning.sawp.po.bi.BiDevelopSale;
import com.suning.sawp.po.bi.BiStaffArriveSaleWeekEntity;
import com.suning.sawp.po.bi.BiStaffDevelopMonthEntity;
import com.suning.sawp.po.bi.BiStaffDevelopWithSale;
import com.suning.sawp.po.bi.BiStaffRecommendSaleWeekEntity;
import com.suning.sawp.service.impl.oga.bi.BIDevelopSaleService;
import com.suning.sawp.service.impl.oga.bi.support.Callback;
import com.suning.sawp.service.impl.oga.bi.support.SimpleRanges;

@Service("biDevelopSaleServiceWeek")
public class BIDevelopSaleServiceWeek extends BIDevelopSaleService {

    @Override
    protected List<? extends BIStaffDevelopSale> queryStaffsArriveSale(String storeCode, String cateCode, int offset) {
        Map<String, Object> paramMap = Maps.newHashMap();
        LocalDate localDate = new LocalDate().plusDays(offset);
        paramMap.put("statsWeekOfYear", localDate.getWeekOfWeekyear());
        paramMap.put("storeCode", storeCode);
        paramMap.put("cateCode", cateCode);
        return dalClient.queryForList("BIDevelopSaleService.queryStaffsArriveSale_WEEK", paramMap,
                BiStaffArriveSaleWeekEntity.class);
    }

    @Override
    protected List<? extends BIStaffDevelopSale> queryStaffsRecommendSale(String storeCode, String cateCode,
            int offset) {
        Map<String, Object> paramMap = Maps.newHashMap();
        LocalDate localDate = new LocalDate().plusDays(offset);
        paramMap.put("statsWeekOfYear", localDate.getWeekOfWeekyear());
        paramMap.put("storeCode", storeCode);
        paramMap.put("cateCode", cateCode);
        return dalClient.queryForList("BIDevelopSaleService.queryStaffsRecommendSale_WEEK", paramMap,
                BiStaffRecommendSaleWeekEntity.class);
    }

    @Override
    protected SimpleRange<String> getStaffSaleRange(int offset) {
        LocalDate localDate = new LocalDate().plusDays(offset);
        SimpleRange<String> range = SimpleRanges.week(localDate,"yyyyMMdd");
        return range;
    }

    @Override
    protected List<? extends BiStaffDevelopWithSale> queryStaffDevelopSaleLeaderBoard(String storeCode, int top,
            int timeOffset) {
        Map<String, Object> paramMap = Maps.newHashMap();
        LocalDate localDate = new LocalDate().plusDays(timeOffset);
        paramMap.put("statsWeekOfYear", localDate.getWeekOfWeekyear());
        paramMap.put("storeCode", storeCode);
        paramMap.put("top", top);
        return dalClient.queryForList("BIDevelopSaleService.queryDevelopSaleLeaderBoard_WEEK", paramMap,
                BiStaffDevelopMonthEntity.class);
    }

    @Override
    protected BiDevelopSale queryStoreDevelopingSale(String storeCode, int offset, Callback<String> span) {
        throw new UnsupportedOperationException("外拓不支持周维度查询");
    }

    @Override
    protected BiDevelopSale queryStoreArriveSale(String storeCode, int offset, Callback<String> span) {
        throw new UnsupportedOperationException("到店不支持门店周维度查询");
    }

    @Override
    protected BiDevelopSale queryStoreRecommendSale(String storeCode, int offset, Callback<String> span) {
        throw new UnsupportedOperationException("推荐不支持门店周维度查询");
    }

    @Override
    protected BIStaffDevelopSale queryStaffDevelopingSale(String storeCode, String staffId, int offset,
            Callback<String> span) {
        throw new UnsupportedOperationException();
    }

    @Override
    protected BIStaffDevelopSale queryStaffArriveSale(String storeCode, String staffId, int offset,
            Callback<String> span) {
        throw new UnsupportedOperationException();
    }

    @Override
    protected BIStaffDevelopSale queryStaffRecommendSale(String storeCode, String staffId, int offset,
            Callback<String> span) {
        throw new UnsupportedOperationException();
    }

    @Override
    protected List<? extends BIStaffDevelopSale> queryStaffsDevelopingSale(String storeCode, String cateCode,
            int offset) {
        throw new UnsupportedOperationException();
    }
}
